package com.shiguiwu.springmybatis.designpattern.adapter;

/**
 * @description: 媒体适配器
 * @author: stone
 * @date: Created by 2021/2/23 16:38
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.adapter
 */
public class MediaAdapter  implements MediaPlayer{


    private AdvancedMediaPlayer advancedMusicPlayer;

    public MediaAdapter(String audioType) {
        if ("mp4".equalsIgnoreCase(audioType)) {
            advancedMusicPlayer = new Mp4Player();
        }
        else if ("vlc".equalsIgnoreCase(audioType)) {
            advancedMusicPlayer = new VlcPlayer();
        }
        else {
            throw new RuntimeException("unSupport play ...");
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if ("mp4".equalsIgnoreCase(audioType)) {
            advancedMusicPlayer.playMp4(fileName);

        }
        else if ("vlc".equalsIgnoreCase(audioType)) {
            advancedMusicPlayer.playVlc(fileName);
        }
        else {
            throw new RuntimeException("unSupport play ...");
        }
    }
}
